<%@ Page Language="C#"  %>
<script runat="server" language="C#">
    
    public Wilson.ORMapper.ObjectSet os = null;

    void Page_Init(object o, EventArgs e)
    {
        Wilson.ORMapper.ObjectSpace engine = Touchmax.Manager.ORManager as Wilson.ORMapper.ObjectSpace;
        Wilson.ORMapper.ObjectQuery oq = new Wilson.ORMapper.ObjectQuery(typeof(Touchmax.AcModule), "ModuleStatus<>'Inactive'", "ModuleSort");
        os = engine.GetObjectSet(oq);
    }   
     
    void Page_Load(object o, EventArgs e)
    {
        
        if (!IsPostBack)
        {
           // BindMenu();
        }
    }

    string GetUserDisplay()
    {
        string user = Page.User.Identity.Name;

        Wilson.ORMapper.ObjectSpace engine = Touchmax.Manager.ORManager as Wilson.ORMapper.ObjectSpace;
        Wilson.ORMapper.ObjectQuery oq = new Wilson.ORMapper.ObjectQuery(typeof(Touchmax.BoEmployee), "Username='" + user + "'", "");
        Wilson.ORMapper.ObjectSet os = engine.GetObjectSet(oq);
        Touchmax.BoEmployee u = os[0] as Touchmax.BoEmployee;
        
        Wilson.ORMapper.ObjectQuery oq1 = new Wilson.ORMapper.ObjectQuery(typeof(Touchmax.BoBranch), "BranchID=" +u.BranchID.ToString(), "");
        Wilson.ORMapper.ObjectSet os1 = engine.GetObjectSet(oq1);
        Touchmax.BoBranch b= os1[0] as Touchmax.BoBranch;
        return string.Format("<table border=0 cellpadding=0 cellspacing=0><tr><td class='txtGroup'>{0}</td><td><img src='/images/group-bar-div.png'></td><td class='txtGroup'>{1}</td></tr></table>", b.BranchName, u.FirstName);        
    }
    
    void BindMenu()
    {
        Wilson.ORMapper.ObjectSpace engine = Touchmax.Manager.ORManager as Wilson.ORMapper.ObjectSpace;
        
        Wilson.ORMapper.ObjectQuery oq = new Wilson.ORMapper.ObjectQuery(typeof(Touchmax.AcModule),"ModuleStatus<>'Inactive'","ModuleSort");
         
        Wilson.ORMapper.ObjectSet os = engine.GetObjectSet(oq);
        
        foreach(Touchmax.AcModule mo in os)
        {
            string where = string.Format("moduleID={0} and FeatureStatus<>'Inactive'", mo.ModuleID);
            Wilson.ORMapper.ObjectQuery oq1 = new Wilson.ORMapper.ObjectQuery(typeof(Touchmax.AcFeature), where , "FeatureSort");
            Wilson.ORMapper.ObjectSet os1 = engine.GetObjectSet(oq1);

            if (os1.Count > 0)
            {
                //NavBarGroup nbg = new NavBarGroup();
                //nbg.Text = mo.DisplayName;
                //ASPxNavBar1.Groups.Add(nbg);
                //foreach (Touchmax.Feature fe in os1)
                //{
                //    NavBarItem nbi = new NavBarItem();
                //    nbi.DataItem = fe;
                //    nbg.Items.Add(nbi);
                //}
            }
            
        }
            
       

    }
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>Colorworks Workspace</title>	
       <style>
           body {margin:0px;overflow:hidden;font-family:Arial;font-size:13px;background-color:White;}
	        div {border:dashed 0px red}
	        #groupbar {height:32px; overflow:hidden;background: url(/images/group-bar-bg.png)}
            .txtGroup {font-size:12px; padding-left:4px; padding-right:4px;}
            .toolbar {height:32px; overflow:hidden;background: url(/images/tool-bar-bg.png)}
            .page {overflow:hidden;border:solid 0px yellow;}
            .frame {overflow:hidden;width:100%;border:solid 0px green;}
            
	        #menubar 
	        {
	                height:36px; 
	                overflow:hidden;
	                background: url(/images/menu-bar-bg.png);
	                border-bottom:1px solid #CCCCCC;
	        }
	
	        #menubar ul {	
		        width:1000px;
		        margin:0 auto;
		        margin-top: 6px;
		        float: left;
	        }
	
	        #menubar li {	
		        border-right:0px solid #ddd;
		        float:left;
		        padding-left:1px;
		        margin-left:10px;
		        margin-right:10px;
		        list-style-type:none;
		        text-align:center;
		        margin-top:0px;
		        margin-left:8px;
	        }
	
	        #menubar a {
		        color:#333333;
		        display:block;
		        padding:8px;
		        position:relative;
		        word-spacing:-2px;
		        font-size:10px;		
		        height:26px;
		        text-decoration:none;
		        	        
	        }	
	
	        #menubar a.current {
		        background:url(http://static.flowplayer.org/tools/img/tabs/down_large.jpg);	
	        }
	
	        #menubar img {
		        background-color:#fff;
		        border:1px solid #ccc;
		        margin:3px 0 5px 27px;
		        padding:4px;		
		        display:block;
	        }
	
	        #menubar strong {
		        display:block;		
		        font-size:11px;
	        }
	        /* panes */
	        #pages {
		        background:#fff;
		        height:600px;
		        margin-bottom:-20px;
		        padding-bottom:20px;
		        /* must be relative so the individual panes can be absolutely positioned */
		        position:relative;
		        border:solid 0px red;
	        }
	
	        /* crossfading effect needs absolute positioning from the elements */
	        #pages div11
	        {
	            width:100%;
		        display:none;		
		        color:#444;	
		        border: solid 0px red;
	        }
	
	        .tab 
	        {
	            width:100%;
	            height:300px;
		        display:none;		
		        color:#444;	
		        border: solid 0px red;
	        }
	        
	        .overlay {
		        display:none;
		        width:500px;
		        padding:20px;
		        background-color:#ddd;
	        }
	
    </style>
    <script type="text/javascript" src="http://cdn.jquerytools.org/1.2.4/full/jquery.tools.min.js"></script>
    <script type="text/javascript" language="javascript">
        var _load = false;
        var _resize = false;

        $(document).ready(function () {

            var h = $(window).height();
            var w = $(window).width();

            $(".tab").css('height', h - 68);
            //$(".frame").css('height', h - 68);
            //$(".page").css('height', h - 100);


            var h1 = h - 68;
            $('.tab').each(function () {
                loadWorkspace($(this).attr("idx"), "", $(this).attr("url") + "?h=" + h1);
            });


            $(window).resize(function () {
                var h = $(window).height();
                var w = $(window).width();
                $(".tab").css('height', h - 68);
             //   $(".frame").css('height', h - 68);
             //   $(".page").css('height', h - 100);
            });



        });


        function loadWorkspace(i, t, u) {
            var h = $(window).height() - 100;

            var s = '<iframe name="space' + i + '" id="space' + i + '" width="100%" height="100%" border="0" frameborder="0" src="' + u + '" ></iframe>';
            $("#tab" + i).html(s);
        }

        function Popup(u, t, w, h) {
            var pop = ASPxClientControl.GetControlCollection().Get("popup");
            pop.SetContentUrl("about:blank");
            pop.SetContentUrl(u);
            pop.SetHeaderText(t);
            pop.Show();
            pop.SetSize(w, h);
        }
        function PopupItem(u, t, w, h) {
            var pop = ASPxClientControl.GetControlCollection().Get("popupItem");
            pop.SetContentUrl("about:blank");
            pop.SetContentUrl(u);
            pop.SetHeaderText(t);
            pop.Show();
            pop.SetSize(w, h);
        }
    </script>
</head>

<body>
<form id="Form1" runat="server" name="form1">


<div id="groupbar">
<table width="100%" border=0 cellspacing=0 cellpadding=0 style="font-weight:bold;" >
<tr>
<td style="padding-left:10px;padding-right:10px;width:50px;"><img src="/images/canadaflag32.png" /></td>
<td nowrap style="padding:0px;padding-left:4px; font-size:14px;">
<%= GetUserDisplay()  %>
</td>
<td width=100%>&nbsp;</td>
<td width=200 nowrap style="width:120px;padding-top:4px;padding-right:10px;" align="right"><a style="text-decoration:none;font-size:12px;color:#666666" href="/framework/logout.ashx">[ Log Out ]</a></td>
</tr>
</table>
</div>

    
<div id="menubar">
	<ul>
     <%   
        int i=0;
        foreach (Touchmax.AcModule mo in os)
        {
            i ++;
            string s = string.Format("<li><a href='#{0}'><strong>{1}</strong></a></li>",i,mo.DisplayName);
            Response.Write(s);
        }
     %>
	</ul>
    <div style="width:220px;font-size:11px;margin-top:12px;margin-right:20px;float:right;">
    <b><%= DateTime.Today.ToLongDateString() %></b>
    </div>
</div>

<div id="pages">

     <%   
        i=0;
        foreach (Touchmax.AcModule mo in os)
        {
            i ++;
            %>
            <div class="tab" id="tab<%= i %>" idx="<%= i %>" url="<%= mo.ModuleUrl %>">
            <%= i %>
            </div>
            <%
        }
     %>

</div>
<dxpc:ASPxPopupControl ID="popup" ClientInstanceName="popup" runat="server" AllowDragging="True"
    AllowResize="True" CloseAction="CloseButton" ContentUrl="about:blank"
    EnableViewState="False" PopupHorizontalAlign="Center" PopupVerticalAlign="Middle" ShowFooter="True" ShowOnPageLoad="False"
    Width="400px" Height="300px" FooterText=""
    HeaderText="" Modal="true" EnableHierarchyRecreation="True">
    <ContentStyle>
        <Paddings Padding="0px"></Paddings>
    </ContentStyle>
</dxpc:ASPxPopupControl>
<dxpc:ASPxPopupControl ID="popupItem" ClientInstanceName="popupItem" runat="server" AllowDragging="True"
    AllowResize="True" CloseAction="CloseButton" ContentUrl="about:blank"
    EnableViewState="False" PopupHorizontalAlign="Center" PopupVerticalAlign="Middle" ShowFooter="True" ShowOnPageLoad="False"
    Width="400px" Height="300px" FooterText=""
    HeaderText="" Modal="true" EnableHierarchyRecreation="True">
    <ContentStyle>
        <Paddings Padding="0px"></Paddings>
    </ContentStyle>
</dxpc:ASPxPopupControl>
<script type="text/javascript">
    $(function () {
        $("#menubar ul").tabs("#pages > div.tab", {});
    });
</script>


</form>

</body>
   
</html>
